<template>
  <div class="p-d">
    <div class="b-f heightStyle p-d">
      <!-- <el-select v-model="selectValue" placeholder="请选择项目种类" @change="initData()">
        <el-option v-for="(item,index) in arr" :key="index" :value="item.projectType" :label="item.projectType">
        </el-option>
      </el-select> -->
      <!-- <div class="m-t"> <el-button type="primary">新增模板</el-button></div> -->
      <TableCompEle class="m-t" ref="multipleTable" v-loading="loading" :tableData="tableData" :tableAction="tableAction" :isSelect="true"
        :isPageIndex="false" :isShowPage="true" :tableConfig="tableConfig" :queryParams="queryParams" @getPagination="initData"
        @handleSelectionChange="handleSelectionChange" />
    </div>
    <Add ref="addRef" @close="initData()" />
  </div>
</template>

<script>
import Add from './common/add.vue'
// import {
//   techTemplate,
// } from "@/api/techTemplate.js"
// import { projectTypeSelect } from '@/api/techParamConfig.js'
export default {
  components: { Add },
  data() {
    return {
      multipleSelection: [],
      selectValue: '',
      arr: [],
      queryParams: {
        total: 0,
        pageNum: 1,
        pageSize: 10,
      },
      loading: false,
      tableData: [{}],
      tableConfig: [
        {
          prop: 'templateName',
          label: '模板名称'
        }, {
          prop: 'modifyTime',
          label: '创建时间'
        }, {
          prop: 'modifyBy',
          label: '创建人'
        }, {
          prop: 'templateRemarks',
          label: '备注'
        },
        {
          prop: 'templateFileName',
          label: '模板文档',
          isLink: true,
          type: "primary",
          method: () => {
            alert(1)
          }
        },
      ],
      tableAction: {
        width: () => "120px",
        fixed: "right",
        operations: [
          {
            label: "修改",
            isLink: true,
            type: "primary",
            method: (row) => {
              this.editUser(row)
            },
          },
          // {
          //   label: "删除",
          //   isLink: true,
          //   type: "danger",
          //   method: (row) => {
          //     this.dels(row)
          //   },
          // },
        ],
      },
    };
  },
  created() {
    // projectTypeSelect({}).then(res => {
    //   this.arr = res?.data ?? [];
    //   this.selectValue = this.arr[0]?.projectType || '';
    //   this.initData()
    // })
  },
  methods: {
    initData() {
      // techTemplate({ projectType: this.selectValue }).then((res) => {
      //   this.tableData = res.data || [];
      // })
    },
    changeStatus(row) {
      this.$confirm(
        `本操作将${row.enableFlag ? '开启' : '关闭'}该用户，是否继续？`,
        '提示',
        {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }
      )
        .then(() => {
          // const params = {
          //   flag: row.enableFlag ? 'y' : 'n',
          //   userIds: [row.userId]
          // }

        })
        .catch(() => {
          this.$message({
            type: 'info',
            message: '已取消'
          })
          this.initData()
        })
    },
    editUser(row) {
      const obj = {
        title: '修改',
        isEdit: 1,
        data: row
      }
      this.$refs.addRef.show(obj)
    },
    dels(row) {
      this.$confirm(`本操作将删除该用户，是否继续？`, '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      })
        .then(() => {
          console.log('[ row ] >', row)
        })
        .catch(() => {
          this.$message({
            type: 'info',
            message: '已取消'
          })
        })
    },
    handleSelectionChange(val) {
      this.multipleSelection = val
    },
  },
}
</script>

<style lang="less" scoped>
  .heightStyle {
    height: 85vh;
  }
</style>
